package week_10.实验3_查找和排序.test;

import week_10.实验3_查找和排序.cn.edu.besti.cs1723.LXY2328.Searching;

import java.util.Arrays;



public class SearchingTest1 {
    public static void main(String[] args) {
        Searching a =new Searching();
        Integer[] temp2=new Integer[]{17, 20 ,23, 28};
        int[] temp ={17, 20 ,23, 28, 40, 43, 45, 56, 67};
        System.out.println("原数组为：");
        for(int p=0;p<temp.length;p++) {
            System.out.print(temp[p] + " ");
        }
        System.out.println();
        //线性查找
        System.out.println("在原数组中用线性查找法寻找20");
        System.out.println(a.linearSearch(temp2,0,3,20));
        //二分查找
        System.out.println("在原数组中用二分查找法寻找20");
        if(a.binarySearch(temp,20)==1)
            System.out.println("true");
        else
            System.out.println("false");
        //插值查找
        System.out.println("在原数组中用插值查找法寻找20");
        if(a.InsertionSearch(temp,20,0,temp.length-1)==1)
            System.out.println("true");
        else
            System.out.println("false");
        //斐波那契查找算法
        System.out.println("在原数组中用斐波那契查找算法寻找23");
        System.out.println(a.fibonacciSearch(temp,23));
        //树表查找
        System.out.println("在原数组中用树表查找法寻找23");
        System.out.println(a.binaryTreeSearch(temp2,0,temp2.length-1,23));
        //分块查找
        System.out.println("在原数组中用分块查找法寻找23");
        System.out.println(a.BlockSearch(temp2,0,temp2.length-1,23));
        //哈希算法
        System.out.println("在原数组中用哈希查找法寻找56");
        System.out.println(a.HashSearch(temp,0,temp.length-1,56));
      }
}
